<template>
    <div>
        <h1>
            微信登录
        </h1>
        <div class="card">
            <kv label="第一步">
                <div> 参考：https://developers.weixin.qq.com/doc/oplatform/Website_App/WeChat_Login/Wechat_Login.html
                    <el-button type="mini" @click="start()">登录</el-button>
                </div>
            </kv>
            <kv label="第二步">
<div id="qrCodeLogin">

</div>
            </kv>

        </div>
    </div>
</template>

<script type="text/ecmascript-6">


    export default {
        components: {},
        data: function () {
            return {}
        },
        mounted() {
            jv.addScriptFile("http://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js");
        },
        methods: {
            start(){
                var obj = new WxLogin({
                    self_redirect:true,
                    id:"qrCodeLogin",
                    appid: "wxf1ae14e01237917f",
                    scope: "snsapi_login",
                    redirect_uri: encodeURIComponent("http://www.91haozu.com/api/open/wx/oauth"),
                    state: jv.random(),
                    style: "black"
                });
            },
            // call() {
            //     var url = "https://open.weixin.qq.com/connect/qrconnect?appid={AppId}&redirect_uri={RedirectUrl}&response_type=code&scope={Scope}&state={State}#wechat_redirect"
            //         .format({
            //             AppId: "wxf1ae14e01237917f",
            //             Scope: "snsapi_login",
            //             RedirectUrl: encodeURIComponent("http://127.0.0.1/wx/oauth"),
            //             State: jv.random()
            //         });
            //
            //     window.open(url);
            // }
        }
    }
</script>

<style scoped>
</style>
